package demo1;

import demo.NameException;

/**
 * Created with IntelliJ IDEA.
 * Description:实现一个简单的控制台版用户登陆程序,
 * 程序启动提示用户输入用户名密码. 如果用户名密码出错, 使用自定义异常的方式来处理
 * User: 86183
 */
public class Login {
    private String userName = "小贺";
    private String password = "040615";

    public String getUserName() {
        return userName;
    }
    public void setUserName(String userName) {
        this.userName = userName;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public void loginInfo(String userName , String password)throws NameException,PasswordException {
        if (!this.userName.equals(userName)){
            throw new NameException("用户名错误");
        }
        if (!this.password.equals(password)){
            throw new PasswordException("密码错误");
        }
    }
}
